<?php

namespace App\Constants;

/**
 * 保险类型枚举
 * 定义各种保险类型和缴费方式
 */
class InsuranceTypeEnum extends AbstractEnum
{
    // 保险类型常量
    public const SOCIAL_INSURANCE = 'social_insurance';
    public const MEDICAL_INSURANCE = 'medical_insurance';
    public const UNEMPLOYMENT_INSURANCE = 'unemployment_insurance';
    public const WORK_INJURY_INSURANCE = 'work_injury_insurance';
    public const MATERNITY_INSURANCE = 'maternity_insurance';
    public const HOUSING_FUND = 'housing_fund';
    public const COMMERCIAL_INSURANCE = 'commercial_insurance';
    public const ACCIDENT_INSURANCE = 'accident_insurance';
    public const HEALTH_INSURANCE = 'health_insurance';
    public const NONE = 'none';

    /**
     * 获取所有枚举实例
     */
    public static function getAll(): array
    {
        return [
            new self('social_insurance', '社保', '社会保险', '#28A745', 'shield-alt', 1),
            new self('medical_insurance', '医保', '医疗保险', '#17A2B8', 'medkit', 2),
            new self('unemployment_insurance', '失业险', '失业保险', '#6C757D', 'user-times', 3),
            new self('work_injury_insurance', '工伤险', '工伤保险', '#DC3545', 'hard-hat', 4),
            new self('maternity_insurance', '生育险', '生育保险', '#E83E8C', 'baby', 5),
            new self('housing_fund', '公积金', '住房公积金', '#FFC107', 'home', 6),
            new self('commercial_insurance', '商业保险', '商业保险公司', '#FD7E14', 'building', 7),
            new self('accident_insurance', '意外险', '意外伤害保险', '#20C997', 'exclamation-triangle', 8),
            new self('health_insurance', '健康险', '健康医疗保险', '#6F42C1', 'heart', 9),
            new self('none', '无保险', '不参加任何保险', '#ADB5BD', 'ban', 10),
        ];
    }

    /**
     * 获取法定保险类型
     */
    public static function getMandatoryInsuranceTypes(): array
    {
        return [
            self::SOCIAL_INSURANCE,
            self::MEDICAL_INSURANCE,
            self::UNEMPLOYMENT_INSURANCE,
            self::WORK_INJURY_INSURANCE,
            self::MATERNITY_INSURANCE,
        ];
    }

    /**
     * 获取五险类型
     */
    public static function getFiveInsurancesTypes(): array
    {
        return [
            self::SOCIAL_INSURANCE,
            self::MEDICAL_INSURANCE,
            self::UNEMPLOYMENT_INSURANCE,
            self::WORK_INJURY_INSURANCE,
            self::MATERNITY_INSURANCE,
            self::HOUSING_FUND,
        ];
    }

    /**
     * 获取商业保险类型
     */
    public static function getCommercialInsuranceTypes(): array
    {
        return [
            self::COMMERCIAL_INSURANCE,
            self::ACCIDENT_INSURANCE,
            self::HEALTH_INSURANCE,
        ];
    }

    /**
     * 检查是否为法定保险
     */
    public static function isMandatoryInsurance(string $type): bool
    {
        return in_array($type, self::getMandatoryInsuranceTypes());
    }

    /**
     * 检查是否为五险一金
     */
    public static function isFiveInsurances(string $type): bool
    {
        return in_array($type, self::getFiveInsurancesTypes());
    }

    /**
     * 检查是否为商业保险
     */
    public static function isCommercialInsurance(string $type): bool
    {
        return in_array($type, self::getCommercialInsuranceTypes());
    }
}
